package edu.ihs.lhpy.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionContext;
import edu.ihs.lhpy.base.BaseAction;
import edu.ihs.lhpy.domain.PageBean;
import edu.ihs.lhpy.domain.StudentsGuide;
@Controller
@Scope("prototype")
public class StudentsGuideAction extends BaseAction<StudentsGuide>{

	//列表
	public String list() throws Exception{
//		List<StudentsGuide> studentsGuideList = studentsGuideService.findAll();
		PageBean pageBean = studentsGuideService.getPageBean(pageNum);
		ActionContext.getContext().getValueStack().push(pageBean);
		return "list";
	}
	//添加
	public String add() throws Exception{
		studentsGuideService.save(model);
		return "toList";
	}
	//添加界面
	public String addUI() throws Exception{
		return "saveUI";
	}
	//删除
	public String delete() throws Exception{
		studentsGuideService.delete(model.getId());
		return "toList";
	}
	//修改
	public String edit() throws Exception{
		StudentsGuide studentsGuide = studentsGuideService.getById(model.getId());
		
		studentsGuide.setAuthor(model.getAuthor());
		studentsGuide.setContent(model.getContent());
		studentsGuide.setTime(model.getTime());
		studentsGuide.setTitle(model.getTitle());
		
		//更新到数据库中
		studentsGuideService.update(studentsGuide);
		return "toList";
	}
	//修改界面
	public String editUI() throws Exception{
		//准备回显数据
		StudentsGuide studentsGuide = studentsGuideService.getById(model.getId());
		ActionContext.getContext().getValueStack().push(studentsGuide);
		return "saveUI";
	}
	
	
}
